<?php include('header.php')?>
<?php
use \LaneWeChat\Core\Db;
use \LaneWeChat\Core\Ext;
$account_id = intval($_GET['account_id']);

if (!$account_id) {
    exit("<script>alert('非法操作！');history.go(-1);</script>");

}
include '/var/www/html/wx/wechat/core/ext.lib.php';
include '/var/www/html/wx/wechat/core/db.lib.php';
//$sql = "SELECT id,username,name,hash,token as wxtoken,encodingAESKey,fid,create_time FROM pft_wx WHERE hash=100014";
$sql = "SELECT ac_type,name,hash,token as wxtoken,encodingAESKey,fid,isconnect FROM pft_wx WHERE id=? LIMIT 1";
$stmt = Db::Connect()->prepare($sql);
$stmt->execute(array($account_id));//array($account_id, $_SESSION['sid'])
$account = $stmt->fetch(PDO::FETCH_ASSOC);
if (!$account) {
    exit("<script>alert('数据不存在，请先登录验证！');location.href='add_account_login.html';</script>");
}
$domain = str_replace('http://', '',Ext::GetWxDomain($_SESSION['sid'], $account['hash']));
//echo $domain;
$url = Ext::GetApiUrl($_SESSION['sid'], $_SESSION['saccount'], $account_id);
?>
	<title>公众号配置</title>
<style>
    .guide em {
        font-style: normal;
        color: #d9534f;
    }
    .clipLinkBtn{ display:inline-block; padding:2px 12px; margin-left:8px; background:#298adc; color:#fff; border-radius:2px;}
    .clipLinkBtn.success{ background:#63bc1b}
    .guide .img {
        margin-bottom: 15px;
        display: inline-block;
        border: 1px solid #cccccc;
        padding: 3px;
    }
    .clipLinkLi{ padding-bottom:10px;}
    .clipLinkLi .lt,.clipLinkLi .rt{ float:left; text-align:left}
    .clipLinkLi .lt{ width:150px; padding-left:20px; color:#c82525}
    .clipLinkLi .rt{}
   .page-header {
        border: none;
        border-left: 0.3em #333 solid;
        padding-left: 1em;
    }
    .page-header:first-child {
        margin-top: 0;
    }
    .page-header {
        padding-bottom: 0;
    }
    .list-group-item h4.page-header{ margin-top:15px;}
</style>
</head>
<body>
	<div class="navbar navbar-inverse navbar-static-top" role="navigation" style="position:static;">
		<div class="container-fluid">
			<ul class="nav navbar-nav">
				<li><a href="http://www.12301.cc"><i class="fa fa-reply-all"></i>返回系统</a></li>
			</ul>
		</div>
	</div>
	<div class="container-fluid">
		<div class="row">
            <?php include('leftbar.php')?>
            <div class="col-xs-12 col-sm-9 col-lg-10">
                <div class="clearfix">
                    <ul class="nav nav-tabs nav-width">
                        <li class="normal"><a href="javascript:;">1. 公众号验证</a></li>
                        <li class="normal"><a href="add_account.html?account_id=<?=$account_id?>">2. 设置公众号信息</a></li>
                        <li class="active"><a href="javascript:;">3. 引导页面</a></li>
                    </ul>
                    <div class="panel panel-default guide">
                        <div class="panel-heading">
                            高级设置
                        </div>
                        <div class="panel-body">
                            <h5 class="alert alert-info">您绑定的微信公众号：<em><?=$account['name']?></em>，请按照下列引导完成配置。</h5>
                            <div class="list-group">
                                <div class="list-group-item">
                                    <h4 class="page-header">登录 <a href="https://mp.weixin.qq.com/" target="_blank">微信公众平台</a>，点击左侧菜单最后一项，进入 [ <em>开发者中心</em> ]</h4>
                                    <div class="con">
                                        <div class="img"><img src="/wx_public/images/guide-01.png"></div>
                                        <p># 如果您未成为开发者，请勾选页面上的同意协议，再点击 [ <em>成为开发者</em> ] 按钮</p>
                                    </div>
                                </div>
                                <div class="list-group-item" id="infoWrap">
                                    <h4 class="page-header">在开发者中心，找到［<em> 服务器配置</em> ］栏目下URL和Token设置</h4>
                                    <div class="con">
                                        <div class="img"><img src="/wx_public/images/guide-02.png"></div>
                                        <p># 将以下链接链接填入对应输入框：</p>
                                        <form action="" method="post" class="form-horizontal" role="form">
                                            <div class="form-group clipLinkLi">
                                                <label class="control-label lt"style="padding-top:0">URL(服务器地址)</label>
                                                <div class="input-group rt">
                                                    <p class="form-control-static" style="padding:0">
                                                        <a href="javascript:;" title="点击复制Token" class="clipTrigger"><?=$url?></a><span data-link="<?=$url?>" class="clipLinkBtn">复制</span>
                                                    </p>
                                                </div>
                                            </div>
                                            <div class="form-group clipLinkLi">
                                                <label class="lt control-label"style="padding-top:0">Token(令牌)</label>
                                                <div class="rt input-group">
                                                    <p class="form-control-static"style="padding:0">
                                                        <a href="javascript:;" title="点击复制Token" class="clipTrigger"><?=$account['wxtoken']?></a><span data-link="<?=$account['wxtoken']?>" class="clipLinkBtn">复制</span>
                                                    </p>
                                                </div>
                                            </div>
                                            <div class="form-group clipLinkLi">
                                                <label class="lt control-label"style="padding-top:0">EncodingAESKey<span style="display:block">(消息加解密密钥)</span></label>
                                                <div class="rt input-group">
                                                    <p class="form-control-static"style="padding:0"> <a href="javascript:;" title="点击复制Token" class="clipTrigger"><?=$account['encodingAESKey']?></a><span data-link="<?=$account['encodingAESKey']?>" class="clipLinkBtn">复制</span>
                                                    </p>
                                                </div>
                                            </div>
                                        </form>
                                        <p># 如果以前已填写过URL和Token，请点击[<em> 修改配置 </em>] ，再填写上述链接</p>
                                        <p># 请点击 [<em> 启用 </em>] ，以启用服务器配置：</p>
                                        <div class="img"><img src="/wx_public/images/guide-03.png" width="524"></div>
                                    </div>
                                </div>
                                <?php if($account['ac_type']==1):?>
                                    <!--认证过的服务号-->
                                    <div class="list-group-item">
                                        <h4 class="page-header">在 [ <em>开发者中心</em> ], <em>接口权限表</em>,找到 <em>网页授权获取用户基本信息</em></h4>
                                        <div class="con">
                                            <div class="img"><img src="/wx_public/images/guide-04.png"></div>
                                        </div>
                                    </div>
                                    <div class="list-group-item">
                                        <h4 class="page-header">点击<em>修改</em></h4>
                                        <div class="con">
                                            <p># 将以下地址填入对应输入框：</p>
                                            <form class="form-horizontal" role="form">
                                                <div class="form-group clipLinkLi">
                                                    <label class="control-label lt"style="padding-top:0">授权回调页面域名</label>
                                                    <div class="input-group rt">
                                                        <p class="form-control-static" style="padding:0">
                                                            <a href="javascript:;" title="点击复制" class="clipTrigger"><?=$domain?></a><span data-link="<?=$url?>" class="clipLinkBtn">复制</span>
                                                        </p>
                                                    </div>
                                                </div>
                                            </form>
                                            <div class="img"><img src="/wx_public/images/guide-05.png"></div>
                                        </div>
                                    </div>
                                <?php endif;?>
                                <div class="list-group-item">
                                    <h4 class="page-header">
                                        <?php if($account['isconnect'] == 0):?>
                                            <em>公众号 <?=$account['name']?> 接入成功</em>
                                        <?php else:?>
                                            <em>公众号 <?=$account['name']?> 正在等待接入……请及时按照以上步骤操作接入公众平台</em>
                                        <?php endif;?>
                                    </h4>
                                    <div class="con">
                                        <?php if($account['isconnect'] == 0):?>
                                            <p># 检查公众平台配置</p>
                                            <p># 编辑公众号 <a href="###"><?=$account['name']?></a></p>
                                            <a href="javascript:window.location.reload();" class="btn btn-success" style="color:#FFF">检测是否接入成功</a>&nbsp;&nbsp;&nbsp;<a href="{php echo url('account/switch', array('uniacid' => $uniacid))}" class="btn btn-primary" style="color:#FFF">暂不接入，先去查看管理功能</a>
                                            <a href="{php echo url('')}" class="btn btn-info" style="color:#FFF">返回公众号列表</a>
                                        <?php else:?>
                                            <a href="{php echo url('account/switch', array('uniacid' => $uniacid))}" class="btn btn-primary" style="color:#FFF">管理公众号</a>
                                        <?php endif;?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

		</div>
	</div>
	<div style="display:none" id="gMaskLayer" class="gMaskLayer"></div>
    <script src="http://www.12301.cc/wx_public/zclip/jquery.zclip.min.js"></script>
    <script>
        $(function(){
            $(".clipLinkBtn").zclip({
                path: "/wx_public/zclip/ZeroClipboard.swf",
                copy: function(){
                    return $(this).attr("data-link");
                },
                deforeCopy : function(){},
                afterCopy : function(){
                    var btn = $(this);
                    btn.text("已复制到剪贴板").addClass("success");
                    WXB.G.Delay.set(function(){
                        btn.removeClass("success").text("复制");
                    },2 * 1000)
                }
            });
        });
    </script>

</body>